<template>
  <el-dialog v-model="visible" title="Shipping address" :before-close="cancel">
    <el-form :model="form">
      <el-form-item label="Promotion name">
        <el-input v-model="form.username" autocomplete="off" />
      </el-form-item>
      <el-form-item label="Promotion name">
        <el-input v-model="form.username" autocomplete="off" />
      </el-form-item>
      <!-- <el-form-item label="Zones">
        <el-select v-model="form.name" placeholder="Please select a zone">
          <el-option label="Zone No.1" value="shanghai" />
          <el-option label="Zone No.2" value="beijing" />
        </el-select>
      </el-form-item> -->
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="cancel">取消</el-button>
        <el-button type="primary" @click="cancel">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import type { AdminListType } from "@/request/admin";
import { Ref } from "vue";
import { ref, reactive, withDefaults, watch } from "vue";
//withDefaults设置组件属性默认值
const props = withDefaults(defineProps<{ visible: boolean }>(), {
  visible: false,
});

const form = ref({}) as Ref<AdminListType>;
watch(
  () => props.data,
  (val) => {
    form.value = { ...val };
  },
  { deep: true }
);
//声明emit
const emit = defineEmits<{ (event: "close"): void }>();
//关闭方法
function cancel() {
  emit("close");
}
</script>

<style></style>
